<?php 
include '../include/init.php';
include '../include/common.fun.php';
include '../include/mysql.config.php';
// 单一职责
islogin();

if($_GET){
	$id = isset($_GET['id'])?$_GET['id']+0:0;
	$sql = "SELECT * FROM wd_service WHERE service_id=$id";
	$service = $db->getOne($sql);

	$res = $db->delete('wd_service','service_id='.$id);
	if($res){
		unlink(SERVICE_PATH.$service['service_img']);
		unlink(SERVICE_PATH.$service['service_img2']);
		alert('删除成功','service_list.php');exit;
	}else{
		alert('删除失败');exit;
	}
}
if($_POST){
	$idarr = $_POST['idarr'];
	if($idarr){
		foreach($idarr as $v){
			$tmp = $db->getOne("SELECT * FROM wd_service WHERE service_id=".$v);

			$res = $db->delete('wd_service','service_id='.$v);
			if($res){
				unlink(SERVICE_PATH.$tmp['service_img']);
				unlink(SERVICE_PATH.$tmp['service_img2']);
			}
		}
		alert('删除成功','service_list.php');
	}
}



